<template>
    <div class="big-box">
        <div class="header">
            <img src="../../../../../assets/bigScreen/header2.png" alt="" />
            <div class="backBox" @click="goBack"></div>
        </div>
        <div class="backToBox">
            <div class="backTo" @click="gotoHome">
                <div>返回总窗口</div>
            </div>
            <div class="backTo" @click="backToOne">
                <div>返回上一页</div>
            </div>
        </div>
        <div class="centerBox">
            <div class="sreenTitle">概念验证机构</div>
            <div class="center">
                <div class="search_box">
                    <div class="search_box_top">
                        <div class="search_box_top_title"></div>
                        <div>
                            <a-input-search v-model:value="searchValue" placeholder="请输入关键词" enter-button="搜索机构" @search="onSearch"
                                style="width: 50rem;background: rgba(68, 148, 255, 0.12);" />
                        </div>
                    </div>
                    <div class="search_box_middle1" style="padding: 3.2rem;padding-bottom: 0;">
                        <div class="search_box_middle_item">
                            <div class="search_box_middle_item_name">机构类目</div>
                            <div class="search_box_middle_item_tag">
                                <div :class="orgTypeIndex == index ? 'search_box_middle_item_tagItem active' : 'search_box_middle_item_tagItem'"
                                    v-for="(item, index) in orgTypeList" @click="orgTypeIndex = index; params.number = 1; getList()"
                                    :key="index">
                                    {{ item.name }}
                                </div>
                            </div>
                            <div class="search_box_middle_item_more"></div>
                        </div>
                        <div class="search_box_middle_item">
                            <div class="search_box_middle_item_name">行业类目</div>
                            <div class="search_box_middle_item_tag" :style="{ height: showMore ? 'initial' : '4.8rem' }">
                                <div :class="fieldIndex == -1 ? 'search_box_middle_item_tagItem active' : 'search_box_middle_item_tagItem'"
                                    @click="fieldIndex = -1; params.number = 1; getList()">全部</div>
                                <div :class="index == fieldIndex ? 'search_box_middle_item_tagItem active' : 'search_box_middle_item_tagItem'"
                                    v-for="(item, index) in fieldList" @click="fieldIndex = index; params.number = 1; getList()"
                                    :key="index">
                                    {{ item.name }}
                                </div>
                            </div>
                            <div class="search_box_middle_item_more" @click="showMore = !showMore">更多分类
                                <img src="../../../../../assets/more-icon.png" alt=""
                                    :style="{ transform: showMore ? 'scaleY(-1)' : 'scaleY(1)' }">
                            </div>
                        </div>
                    </div>
                    <div class="search_box_bottom" v-if="orgList.length">
                        <div class="search_box_bottom_content">
                            <div class="search_box_bottom_content_item" v-for="(item, index) in orgList"
                                @click="goOrgDetail(item.id)">
                                <div class="search_box_bottom_content_item_left">
                                    <img :src="item.imgUrls ? item.imgUrls[0] == '/' ? baseUrl + item.imgUrls : item.imgUrls : '../../../../../assets/org_default.png'"
                                        alt="暂无图片" style="width:100%;height:100%" />
                                </div>
                                <div class="search_box_bottom_content_item_right">
                                    <div class="item_title">
                                        <!-- <img src="../../../../../assets/news.png" alt="" style="width: 4rem;"> -->
                                        <span>{{ item.name ? item.name.length > 20 ? item.name.slice(0,
                                            19) : item.name : '' }}</span>
                                    </div>
                                    <div class="item_content">{{ item.address }}</div>
                                    <div class="item_info">
                                        <div class="item_info_item">
                                            <img src="../../../../../assets/phone.png" alt=""
                                                style="width:1.8rem;height:1.8rem;margin-top:0.5rem">
                                            <div style="margin-left: 1rem;color: #FFFFFF;">联系电话：{{ item.phone }}</div>
                                        </div>
                                        <div class="item_info_item">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div style="text-align: center;padding: 5rem 0;" v-if="orgList.length">
                        <a-pagination v-model:current="params.number" v-model:pageSize="params.size" :total="params.total" :show-size-changer="false" @change="onShowSizeChange" />
                    </div>
                    <no-Data v-else />
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { baseUrl } from '../../../../../../config';
import { ref, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import noData from "../../../no-data.vue"
import {
    getResearchOrganization,
    getTechField,
    getExportDomain,
    getExportLabel,
    getExpert,
    getArea
} from "../../../../../api/scientificResearch.js"
const router = useRouter()
const pageAct = ref(1)
const dates = ref('')
const route = useRoute()

const orgTypeList = ref([{
    name: '全部',
    type: 0
}, {
    name: '自治区重点实验室',
    type: 1
}, {
    name: '技术创新中心',
    type: 2
}, {
    name: '高新技术企业',
    type: 3
}, {
    name: '科技型中小企业',
    type: 4
}, {
    name: '企业研究开发中心',
    type: 5
}, {
    name: '临床医学研究中心',
    type: 6
}, {
    name: '成果转移转化示范区',
    type: 7
}, {
    name: '成果平台',
    type: 8
}, {
    name: '国家重点实验室',
    type: 9
}, {
    name: '成果转移转化示范基地',
    type: 10
}, {
    name: '中试熟化',
    type: 11
},{
    name: '概念验证机构',
    type: 12
}])

const fieldList = ref()
const getFieldList = () => {
    getTechField().then(res => {
        if (res.code === 200) {
            fieldList.value = res.data;
        }
    })
}

const showMore = ref(false)
const searchValue = ref()
const fieldIndex = ref(-1)
const orgTypeIndex = ref(0)
const params = ref({
    number: 1,
    size: 4,
    total: 0,
})
const orgList = ref([])
const getList = () => {
    let datas = {
        size: params.value.size,
        number: params.value.number,
        industry: fieldIndex.value == -1 ? '' : fieldList.value[fieldIndex.value].name,
        name: searchValue.value,
        orgClass: orgTypeIndex.value == 0 ? '' : orgTypeList.value[orgTypeIndex.value].name
    }
    getResearchOrganization(datas).then(res => {
        if (res.code === 200) {
            orgList.value = res.data.list;
            params.value.total = res.data.total ? res.data.total : 0;
        }
    })
}

const onShowSizeChange = (current, pageSize) => {
    params.value.number = current
    params.value.size = pageSize
    getList()
}

const goOrgDetail = (id) => {
    router.push({
        path: '/bigScreen/textOrgDetail',
        query: {
            id,
            name: '中试熟化机构'
        }
    })
}

const onSearch = () => {
    params.value.number = 1
    getList()
}

//判断时间是否为个位数，如果时间为个位数就在时间之前补上一个“0”
const check = (val) => {
    if (val < 10) {
        return '0' + val
    } else {
        return val
    }
}

const gotoScreen = (act) => {
    router.push({
        path: '/bigScreen',
        query: {
            act: act,
        },
    })
}
const gotoHome = (act) => {
    router.push({
        path: '/bigScreenIndex',
    })
}
const backToOne = (act) => {
    router.go(-1)
}

const goBack = () => {
    router.push('/chart')
}

// gotoHome() {
//             router.push({
//                 path: '/bigScreenIndex',
//             })
//         },
//         backToOne() {
//             router.go(-1)
//         },

const displayTime = () => {
    //获取系统当前的年、月、日、小时、分钟、毫秒
    let date = new Date()
    let year = date.getFullYear()
    let month = date.getMonth() + 1
    let day = date.getDate()
    let hour = date.getHours()
    let minutes = date.getMinutes()
    let seconds = date.getSeconds()
    dates.value = `${year}年${month}月${day}日 ${check(hour)}:${check(minutes)}:${check(seconds)}`
}
//每隔1秒调用一次displayTime函数
const start = () => {
    setInterval(() => {
        displayTime()
    }, 1000) //单位是毫秒
}
onMounted(() => {
    start()
    getFieldList()
    getList()
})
</script>

<style scoped lang="scss">
@font-face {
    font-family: "ffa";
    src: url(../../../assets/bigScreen/fonts/DS-DIGIB.TTF);
}
ul,
li {
    list-style: none;
}

::v-deep {
    .ant-btn-primary {
        border-color: #037AFF;
        background: #037AFF;
    }

    .ant-input {
        background: rgba(68, 148, 255, 0.12);
        border: none;
        color: #FFFFFF;
    }

    .ant-pagination-item {
        background: rgba(8, 26, 48, 0.8);
        border: 1px solid #0B2F5F;
    }

    .ant-pagination-item a {
        color: #FFFFFF;
    }

    .ant-pagination-prev .ant-pagination-item-link,
    .ant-pagination-next .ant-pagination-item-link {
        background: rgba(8, 26, 48, 0.8);
        border: 1px solid #0B2F5F;
        color: #707981;
    }

    .ant-pagination-disabled .ant-pagination-item-link {
        background: rgba(8, 26, 48, 0.8);
        border: 1px solid #0B2F5F;
        color: #707981;
    }

    .ant-pagination-item-active {
        background: #004DFD;
        border-radius: 2px;
        border: none;
    }
    .ant-pagination-jump-prev .ant-pagination-item-container .ant-pagination-item-ellipsis, 
    .ant-pagination-jump-next .ant-pagination-item-container .ant-pagination-item-ellipsis {
        color: #FFFFFF;
    }
}

.big-box {
    background-color: #071c3b;
    height: 100vh;
}
.header {
    position: relative;
    text-align: center;
    position: relative;
    height: 19.1rem;

    .backBox {
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 70rem;
        height: 10rem;
        cursor: pointer;
    }

    > img {
        width: 100%;
        max-height: 100%;
        margin-top: -1.1rem;
        image-rendering: -moz-crisp-edges; /* Firefox */
        image-rendering: -o-crisp-edges; /* Opera */
        image-rendering: -webkit-optimize-contrast; /* Webkit (non-standard naming) */
        image-rendering: crisp-edges;
        -ms-interpolation-mode: nearest-neighbor; /* IE (non-standard property) */
    }
}
.centerBox {
    width: 96%;
    margin: 0 auto;
    position: absolute;
    top: 14rem;
    left: 2%;
    .sreenTitle {
        background-image: url("../../../../../assets/bigScreen/sreenTitle.png");
        background-size: 100% 100%;
        height: 3.8rem;
        padding-left: 35px;
        font-weight: 600;
        color: #fff;
        display: flex;
        align-items: center;
    }
    .center {
        margin-top: 1rem;
        height: calc(100vh - 20rem);
        border: 1px solid;
        border-image: linear-gradient(
                130deg,
                #2385df 0%,
                rgba(35, 133, 223, 0.65) 92%
            )
            1;
        padding-bottom: 1rem;
        overflow: auto;
    }
    .center::-webkit-scrollbar {
        display: none;
    }
}
.backToBox {
    position: absolute;
    top: 8rem;
    right: 2%;
    display: flex;
    .backTo {
        background-image: url("../../../../../assets/bigScreen/backTo.png");
        color: #2dccff;
        background-size: 100% 100%;
        width: fit-content;
        padding: 2px 40px 10px 10px;
        font-weight: 600;
        cursor: pointer;
        margin-left: 10px;
        div {
            padding-top: 5px;
        }
    }
}
.search_box {
    width: 140rem;
    margin: 3rem auto 0;
    padding: 3rem 4rem 0rem;

    .personnel-list {
        display: flex;
        flex-wrap: wrap;

        .personnel-item {
            width: 42rem;
            margin: 3rem 1rem 0;
            min-height: 15.6rem;
            border-radius: 0.8rem;
            background: #FFFFFF;
            border: 1px solid #CCCCCC;
            display: flex;
            padding: 2.5rem 4rem;
            padding: 2.5rem 1rem 2.5rem 4rem;
            cursor: pointer;

            .personnel-massage {
                font-family: PingFangSC-Regular;
                font-size: 1.6rem;
                font-weight: normal;
                line-height: 1.9rem;
                color: #393939;
                display: block;

                >div {
                    display: flex;
                    align-items: center;
                    width: 100%;
                }

                .label {
                    border-radius: 0.4rem;
                    margin: 1.6rem 0;
                    padding: 0.6rem 0.8rem;
                    color: #037AFF;
                    background: #E3EDFF;
                }

                .name {
                    width: 10rem;
                    font-family: PingFangSC-Semibold;
                    font-size: 2.4rem;
                    min-height: 2.4rem;
                    line-height: 2.4rem;
                    font-weight: normal;
                    color: #000000;
                    margin-right: 2rem;
                    overflow: hidden; //溢出内容隐藏
                    text-overflow: ellipsis; //文本溢出部分用省略号表示
                    display: -webkit-box; //特别显示模式
                    -webkit-line-clamp: 2; //行数
                    line-clamp: 2;
                    -webkit-box-orient: vertical; //盒子中内容竖直排列
                }
            }

            img {
                width: 10rem;
                height: 10rem;
                border-radius: 50%;
                margin-right: 3rem;
            }
        }
    }

    .search_box_top {
        display: flex;
        justify-content: space-between;
        align-content: center;
        padding-bottom: 3rem;
        border-bottom: 0.1rem solid #EEEEEE;

        .search_box_top_title {
            font-size: 2.4rem;
            color: #037AFF;
        }
    }

    .search_box_middle1 {
        padding: 2rem 0 0 0;
        position: relative;

        .p-num {
            position: absolute;
            right: 0;
            top: 3.2rem;
            width: 20%;
            height: 17.4rem;
            border-left: 1px solid #D8D8D8;
            color: #888888;
            font-size: 1.8rem;
            text-align: center;

            span {
                font-size: 3.6rem;
                color: #CE0000;
                margin-top: 2.8rem
            }
        }

        .search_box_middle_item {
            display: flex;
            justify-content: space-between;
            align-items: start;
            // padding-bottom: 3rem;

            .search_box_middle_item_name {
                width: 8%;
                font-size: 1.8rem;
                color: #FFFFFF;
            }

            .search_box_middle_item_tag {
                width: 84%;
                display: flex;
                flex-wrap: wrap;
                overflow: hidden;
                // justify-content: space-between;

                .search_box_middle_item_tagItem {
                    font-size: 1.6rem;
                    color: rgba(255, 255, 255, 0.85);
                    cursor: pointer;
                    margin-right: 3rem;
                    margin-bottom: 3rem;
                }

                .active {
                    border-radius: .4rem;
                    // background: rgba(3, 122, 255, 0.1);
                    // color: #037AFF;
                    background: #037AFF !important;
                    color: #FFFFFF !important;
                    padding: 0.3rem 1.4rem;
                }
            }

            .search_box_middle_item_more {
                width: 10%;
                font-size: 1.6rem;
                color: #037AFF;
                text-align: right;
                display: flex;
                align-items: center;
                justify-content: flex-end;
                cursor: pointer;

                img {
                    margin-left: 1rem;
                }
            }
        }
    }

    .search_box_bottom {


        .search_box_bottom_title {
            font-size: 2.4rem;
            color: #037AFF;
        }

        .search_box_bottom_content {
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
            padding-top: 1.4rem;

            .search_box_bottom_content_item {
                display: flex;
                justify-content: left;
                align-items: center;
                width: 65rem;
                height: 16rem;
                border-radius: 8px;
                background: #082853;
                box-sizing: border-box;
                border: 1px solid #104B99;
                margin-bottom: 2rem;
                padding: 2rem;
                cursor: pointer;

                .search_box_bottom_content_item_left {
                    width: 12rem;
                    height: 12rem;
                }

                .search_box_bottom_content_item_right {
                    display: flex;
                    justify-content: space-between;
                    flex-direction: column;
                    height: 100%;
                    width: calc(100% - 14rem);
                    margin-left: 2rem;

                    .item_title {
                        display: flex;
                        align-items: center;
                        font-size: 2rem;
                        color: #FFFFFF;
                    }

                    .item_content {
                        font-size: 1.6rem;
                        color: rgba(255, 255, 255, 0.85);
                        text-overflow: -o-ellipsis-lastline;
                        overflow: hidden; //溢出内容隐藏
                        text-overflow: ellipsis; //文本溢出部分用省略号表示
                        display: -webkit-box; //特别显示模式
                        -webkit-line-clamp: 2; //行数
                        line-clamp: 2;
                        -webkit-box-orient: vertical; //盒子中内容竖直排列
                    }

                    .item_info {
                        display: flex;
                        justify-content: space-between;
                        font-size: 1.6rem;
                        color: #555555;

                        .item_info_item {
                            display: flex;
                            // align-items: center;
                        }
                    }
                }
            }
        }
    }
}
</style>
